package flash.utils;

import java.io.IOException;

public class CountByteArray extends ByteArray {
	
	private int count = 0;
	
	public int getCount() {
		return count;
	}
	
	public CountByteArray() {
		
	}
	
	public void reset() {
		count = 0;
	}

	@Override
	public short readShort() throws IOException {
		return 0;
	}

	@Override
	public int readInt() throws IOException {
		return 0;
	}

	@Override
	public String readUTF() throws IOException {
		return "";
	}

	@Override
	public double readDouble() throws IOException {
		return 0;
	}

	@Override
	public float readFloat() throws IOException {
		return 0;
	}

	@Override
	public void writeInt(int value) throws IOException {
		count += 4;
	}

	@Override
	public void writeDouble(double value) throws IOException {
		count += 8;
	}

	@Override
	public void writeUTF(String value) throws IOException {
		if (value != null && value.length() > 0) {
			byte[] bytes = value.getBytes("UTF-8");
			count += bytes.length + 2;
		}
		else {
			count += 2;
		}
	}

	@Override
	public void writeShort(int value) throws IOException {
		count += 2;
	}

	@Override
	public void writeFloat(float value) throws IOException {
		count += 4;
	}

	@Override
	public void writeBytes(byte[] value) throws IOException {
		assert (value.length < (2<<14));
		count += value.length+2;
	}

	@Override
	public byte[] readBytes() throws IOException {
		return null;
	}

}


